﻿using System;
using UnityEngine;
using UnityEngine.UI;

namespace RootMotion.Demos
{
	// Token: 0x020000D4 RID: 212
	[RequireComponent(typeof(VRInteractionController))]
	public class VRInteractionUI : MonoBehaviour
	{
		// Token: 0x06000637 RID: 1591 RVA: 0x0000602A File Offset: 0x0000422A
		public void Start()
		{
			this.interactionController = base.GetComponent<VRInteractionController>();
			this.sliderImages = this.slider.GetComponentsInChildren<Image>();
		}

		// Token: 0x06000638 RID: 1592 RVA: 0x00006049 File Offset: 0x00004249
		public void Update()
		{
			this.UpdateInteractionSlider();
			this.UpdateCursor();
		}

		// Token: 0x06000639 RID: 1593 RVA: 0x0003913C File Offset: 0x0003733C
		public void UpdateInteractionSlider()
		{
			if (this.interactionController.triggerProgress <= 0f || this.interactionController.currentTrigger == null)
			{
				this.slider.gameObject.SetActive(false);
				return;
			}
			this.slider.gameObject.SetActive(true);
			this.slider.transform.rotation = this.interactionController.currentTrigger.transform.GetChild(0).rotation;
			this.slider.transform.position = this.interactionController.currentTrigger.transform.GetChild(0).position;
			this.slider.value = this.interactionController.triggerProgress;
			this.SetSliderAlpha(this.alphaToProgress.Evaluate(this.slider.value));
		}

		// Token: 0x0600063A RID: 1594 RVA: 0x00039220 File Offset: 0x00037420
		public void UpdateCursor()
		{
			if (!(this.interactionController.currentTrigger != null) || !(this.interactionController.currentTrigger.tag == "ShowCursor") || !(this.interactionController.interactionSystem.raycastHit.collider != null))
			{
				this.cursor.gameObject.SetActive(false);
				return;
			}
			this.cursor.gameObject.SetActive(true);
			this.cursor.transform.position = this.interactionController.interactionSystem.raycastHit.point;
		}

		// Token: 0x0600063B RID: 1595 RVA: 0x000392D0 File Offset: 0x000374D0
		public void SetSliderAlpha(float a)
		{
			ColorBlock colors = this.slider.colors;
			colors.normalColor = new Color(this.slider.colors.normalColor.r, this.slider.colors.normalColor.g, this.slider.colors.normalColor.b, a);
			this.slider.colors = colors;
			foreach (Image image in this.sliderImages)
			{
				image.color = new Color(image.color.r, image.color.g, image.color.b, a);
			}
		}

		// Token: 0x04000564 RID: 1380
		public const string showCursorTag = "ShowCursor";

		// Token: 0x04000565 RID: 1381
		[Header("Triggering Progress")]
		[Tooltip("The UI slider for showing interaction triggering progress.")]
		public Slider slider;

		// Token: 0x04000566 RID: 1382
		[Tooltip("Alpha of the progress slider relative to the progress of triggering interactions.")]
		public AnimationCurve alphaToProgress;

		// Token: 0x04000567 RID: 1383
		[Tooltip("Reference to the cursor that displays where the head is looking.")]
		public Transform cursor;

		// Token: 0x04000568 RID: 1384
		public VRInteractionController interactionController;

		// Token: 0x04000569 RID: 1385
		public Image[] sliderImages;
	}
}
